﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using Project.Model;

namespace Project.View
{
    public partial class PionPanel : Panel
    {
        private Pion pion;
        private Color color;

        public PionPanel(Pion pion, Color color)
            : base()
        {
            this.pion = pion;
            this.color = color;
            this.Size = new Size(44, 44);
            this.Location = new Point(8, 8);
            this.BackColor = System.Drawing.Color.Transparent;
            this.Click += new System.EventHandler(PionPanel_Click);
            this.DoubleBuffered = true;
        }

        // OnPaint Override
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            SolidBrush brush = new SolidBrush(this.color);
            e.Graphics.FillEllipse(brush, 0, 0, 44, 44);
        }
        
        public void addBorder()
        {
            //this.Parent.CreateGraphics().DrawEllipse(new Pen(new SolidBrush(Color.White), 2), 7, 7, 46, 46);
            //this.Invalidate();
            //this.Refresh();
        }

        public void removeBorder()
        {
            //this.BorderStyle = BorderStyle.None;
            //this.Invalidate();
        }

        // Click Event
        private void PionPanel_Click(object sender, EventArgs e)
        {
            if (this.pion.Move)
            {
                this.pion.VerplaatsPion();
            }
        }
    }
}
